<?php
class omekpi_mdl_deliverier_log extends dbeav_model{

    function getPageData($where=''){
        return $this->db->select('SELECT sdb_omekpi_deliverier_log.* , sdb_omekpi_employee.* ' .
                'FROM `sdb_omekpi_deliverier_log` INNER JOIN sdb_omekpi_employee ' .
                'ON sdb_omekpi_deliverier_log.employee_id = sdb_omekpi_employee.employee_id and sdb_omekpi_employee.employee_type='."'".'deliverier'."' ".$where);
    }

    function getCount($where=''){
        $array=array();
        $count = $this->db->select('select delivery_numbers,deliveried_numbers from sdb_omekpi_deliverier_log '.$where.' limit 1');
        if($count){ 
            foreach($count as $key=>$value){
                $array =  $value;
            }
        }
        $sum = $this->db->select( 'select sum(my_deliveried_numbers) as count_my_deliveried_numbers from sdb_omekpi_deliverier_log '.$where);
        foreach($sum as $k=>$v){
            return array_merge($array,$v);
        }
    }

    function search($where){
        return $this->db->select("SELECT * FROM sdb_omekpi_deliverier_log ".$where);
    }
    
    function update($addarray){
        return $this->db->exec("update sdb_omekpi_deliverier_log set " .
                "my_deliveried_numbers='".$addarray['my_deliveried_numbers']."'".
                " where employee_id='".$addarray['employee_id']."' and createdate='".$addarray['createdate']."'"); 
    }
    
    function getDeliveried_numbers(){
        $arr = $this->db->select('select deliveried_numbers from sdb_omekpi_deliverier_log limit 1');   
        foreach($arr as $k=>$v){
            return $v;
        }
    }
    
    function updateDeliveried($num){
        return $this->db->exec('update sdb_omekpi_deliverier_log set deliveried_numbers='.$num);
    }
    
    function updateCount($count){
        return $this->db->exec('update sdb_omekpi_deliverier_log set delivery_numbers='.$count);
    }
    
    function getdump($array){
   		return $this->db->select('select * from ');
   	}
    
}
    
?>
